package com.example.flow.controller;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.flow.biz.FlowConfigBiz;
import com.example.flow.request.FlowDeployRequest;
import com.example.flow.request.RedeployRequest;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author tangaq
 * @date 2020/11/25
 */
@RestController
@RequestMapping("/flow/config")
public class FlowConfigController {
    @Autowired
    private FlowConfigBiz flowConfigBiz;

    @RequestMapping("/deploy")
    public void deploy(MultipartFile file) throws IOException {
        flowConfigBiz.deploy(file.getBytes());
    }

    @RequestMapping("/reDeploy")
    public void deploy(@RequestBody RedeployRequest request) throws IOException {
        flowConfigBiz.reDeploy(request.getProcessId(), request.getFile()
            .getBytes());
    }
}
